<template>
  <div>
      <h1>当前求和为:{{$store.state.sum}}</h1>
      <select v-model.number="number">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
      </select>&nbsp;
      <button @click="increment">点我奇数加一</button>&nbsp;
      <button @click="decrement">点我减一</button>&nbsp;
      <button @click="incrementOdd">点我奇数加一</button>&nbsp;
      <button @click="incrementWait">点我延时500ms加一</button>
  </div>
</template>

<script>
export default {
    name:'Count',
    data(){
       return{
            number:1
       }
    },
    methods:{
        increment(){
            // 通过dispatch 指挥mutations中的JIA
            // this.$store.dispatch('jia',this.number)
            this.$store.commit('JIA',this.number)
        },
        decrement(){
            // 通过dispatch 指挥mutations中的JIAN
            // this.$store.dispatch('jian',this.number)
            this.$store.commit('JIAN',this.number)
        },
        incrementOdd(){
            this.$store.dispatch('jiaOdd',this.number)
        },
        incrementWait(){
            this.$store.dispatch('jiaWait',this.number)
        },
    },
    mounted(){
        console.log(this.$store)
    }
}
</script>

<style>

</style>